
export function getTodayMonth(fmt) {
    var m = new Date();
    var o = {
        "M+": m.getMonth() + 1,
        "d+": m.getDate(),
        "h+": m.getHours(),
        "m+": m.getMinutes(),
        "s+": m.getSeconds(),
        "q+": Math.floor((m.getMonth() + 3) / 3),
        "S": m.getMilliseconds()
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (m.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}

export function getTime() {
    
    var date = new Date();
    // var month = date.getMonth() + 1;
    // var strDate = date.getDate();
    // if (month >= 1 && month <= 9) {
    //     month = "0" + month;
    // }
    // if (strDate >= 0 && strDate <= 9) {
    //     strDate = "0" + strDate;
    // }

    var hours = date.getHours();
    if (hours >= 0 && hours <= 9) {
        hours = "0" + hours;
    }

    var min = date.getMinutes();
    if (min >= 0 && min <= 9) {
        min = "0" + min;
    }

    // var seconds = date.getSeconds();
    // if (seconds >= 0 && seconds <= 9) {
    //     seconds = "0" + seconds;
    // }
    return  hours + ':' + min
}

export function getTodayTime(fmt) {
    var m = new Date();
    var o = {
        "M+": m.getMonth() + 1,
        "d+": m.getDate(),
        "h+": m.getHours(),
        "m+": m.getMinutes(),
        "s+": m.getSeconds(),
        "q+": Math.floor((m.getMonth() + 3) / 3),
        "S": m.getMilliseconds()
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (m.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}

export function getTodayWeek() {
    var str = '';
    var week = new Date().getDay();
    if (week == 0) {
        str = "周日";
    } else if (week == 1) {
        str = "周一";
    } else if (week == 2) {
        str = "周二";
    } else if (week == 3) {
        str = "周三";
    } else if (week == 4) {
        str = "周四";
    } else if (week == 5) {
        str = "周五";
    } else if (week == 6) {
        str = "周六";
    }
    return str;
}